package ink.tsg.pool.mqtt;

import io.vertx.mqtt.MqttClientOptions;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author tsg
 * @version 1.0
 * @description: MqttClientProperties
 * @date 2022/4/28 10:13
 */
@Component
@ConfigurationProperties(prefix = "mqtt.client")
public class MqttClientProperties {

    // ftp地址
    private String host = MqttClientOptions.DEFAULT_HOST;
    // 端口号
    private Integer port = MqttClientOptions.DEFAULT_PORT;
    // 登录用户
    private String username;
    // 登录密码
    private String password;

    // 连接超时时间(秒)
    private Integer connectTimeout;

    // 等待mqtt回应的超时时间
    private Integer ackTimeout =MqttClientOptions.DEFAULT_ACK_TIMEOUT;

    private boolean autoGeneratedClientId = true;

    private boolean autoKeepAlive ;

    private boolean cleanSession ;

    private boolean willFlag ;

    private int willQoS;

    private boolean willRetain;

    private int keepAliveInterval = MqttClientOptions.DEFAULT_KEEP_ALIVE_INTERVAL;

    private int maxInflightQueue;

    private int maxMessageSize = MqttClientOptions.DEFAULT_MAX_MESSAGE_SIZE;

    private String willMessage;

    private String willTopic;

    // 连接池的配置
    private int minIdle = 3;

    private int maxTotal = 8;

    private int maxIdle = 8;

    private int maxWaitMillis = 6000;

    // 为true时borrowMaxWaitMillis才有作用
    private boolean blockWhenExhausted = true;

    // 设置成true才会调用工厂验证
    private boolean testOnBorrow = true;

    private boolean testOnReturn;

    private boolean testWhileIdle;

    private boolean jmxEnabled = false;

    private boolean fairness;

    private boolean maxWaitDuration;

    public int getMinIdle() {
        return minIdle;
    }

    public void setMinIdle(int minIdle) {
        this.minIdle = minIdle;
    }

    public boolean isBlockWhenExhausted() {
        return blockWhenExhausted;
    }

    public void setBlockWhenExhausted(boolean blockWhenExhausted) {
        this.blockWhenExhausted = blockWhenExhausted;
    }

    public boolean isTestOnBorrow() {
        return testOnBorrow;
    }

    public void setTestOnBorrow(boolean testOnBorrow) {
        this.testOnBorrow = testOnBorrow;
    }

    public boolean isTestOnReturn() {
        return testOnReturn;
    }

    public void setTestOnReturn(boolean testOnReturn) {
        this.testOnReturn = testOnReturn;
    }

    public boolean isTestWhileIdle() {
        return testWhileIdle;
    }

    public void setTestWhileIdle(boolean testWhileIdle) {
        this.testWhileIdle = testWhileIdle;
    }

    public boolean isJmxEnabled() {
        return jmxEnabled;
    }

    public void setJmxEnabled(boolean jmxEnabled) {
        this.jmxEnabled = jmxEnabled;
    }

    public boolean isFairness() {
        return fairness;
    }

    public void setFairness(boolean fairness) {
        this.fairness = fairness;
    }

    public boolean isMaxWaitDuration() {
        return maxWaitDuration;
    }

    public void setMaxWaitDuration(boolean maxWaitDuration) {
        this.maxWaitDuration = maxWaitDuration;
    }

    // 客户端id，默认当前时间戳
    public String clientId;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getConnectTimeout() {
        return connectTimeout;
    }

    public void setConnectTimeout(Integer connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    public Integer getAckTimeout() {
        return ackTimeout;
    }

    public void setAckTimeout(Integer ackTimeout) {
        this.ackTimeout = ackTimeout;
    }

    public boolean isAutoGeneratedClientId() {
        return autoGeneratedClientId;
    }

    public void setAutoGeneratedClientId(boolean autoGeneratedClientId) {
        this.autoGeneratedClientId = autoGeneratedClientId;
    }

    public boolean isAutoKeepAlive() {
        return autoKeepAlive;
    }

    public void setAutoKeepAlive(boolean autoKeepAlive) {
        this.autoKeepAlive = autoKeepAlive;
    }

    public boolean isCleanSession() {
        return cleanSession;
    }

    public void setCleanSession(boolean cleanSession) {
        this.cleanSession = cleanSession;
    }

    public boolean isWillFlag() {
        return willFlag;
    }

    public void setWillFlag(boolean willFlag) {
        this.willFlag = willFlag;
    }

    public int getWillQoS() {
        return willQoS;
    }

    public void setWillQoS(int willQoS) {
        this.willQoS = willQoS;
    }

    public boolean isWillRetain() {
        return willRetain;
    }

    public void setWillRetain(boolean willRetain) {
        this.willRetain = willRetain;
    }

    public int getKeepAliveInterval() {
        return keepAliveInterval;
    }

    public void setKeepAliveInterval(int keepAliveInterval) {
        this.keepAliveInterval = keepAliveInterval;
    }

    public int getMaxInflightQueue() {
        return maxInflightQueue;
    }

    public void setMaxInflightQueue(int maxInflightQueue) {
        this.maxInflightQueue = maxInflightQueue;
    }

    public int getMaxMessageSize() {
        return maxMessageSize;
    }

    public void setMaxMessageSize(int maxMessageSize) {
        this.maxMessageSize = maxMessageSize;
    }

    public String getWillMessage() {
        return willMessage;
    }

    public void setWillMessage(String willMessage) {
        this.willMessage = willMessage;
    }

    public String getWillTopic() {
        return willTopic;
    }

    public void setWillTopic(String willTopic) {
        this.willTopic = willTopic;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public int getMaxTotal() {
        return maxTotal;
    }

    public void setMaxTotal(int maxTotal) {
        this.maxTotal = maxTotal;
    }

    public int getMaxIdle() {
        return maxIdle;
    }

    public void setMaxIdle(int maxIdle) {
        this.maxIdle = maxIdle;
    }

    public int getMaxWaitMillis() {
        return maxWaitMillis;
    }

    public void setMaxWaitMillis(int maxWaitMillis) {
        this.maxWaitMillis = maxWaitMillis;
    }
}
